﻿<%@ WebHandler Language="C#" Class="GetNameByDepid" %>

using System;
using System.Web;
using System.Data.SqlClient;

public class GetNameByDepid : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string NameResult = "";
        string userNameResult = "";
        string type = context.Request.QueryString["depid"].ToString();
        DBOperation DBO = new DBOperation();
        string sql = "select TRUENAME,USERNAME from users where depid=" + type + " and USERNAME<>'admin'";

        SqlDataReader reader = DBO.GetDataReader(sql);
        while (reader.Read())
        {
            NameResult += reader[0] + ";";
            userNameResult += reader[1] + ";";
        }
        NameResult = NameResult + "|||" + userNameResult;
        context.Response.Write(NameResult);
        reader.Close();
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}